---
sidebar_position: 3
title: Adapter
sidebar_label: Adapter
---

<div class="api-link">
  <div class="api-link-title">adapter</div>
  <div class="api-link-sub-title">

[Read the API Reference »](/api/Hyper-Fetch/Function/adapter.mdx)

  </div>
</div>

---

## Introduction

**`Adapter`** is a function that is responsible for communication with the server. The default adapter is used to
communicate with the REST server. However, there is nothing to prevent you from changing this and creating the adapter
you need. Thanks to event communication, you can set your own adapter as you wish.

By default, the adapter is responsible for requests, but its role is very significant for many other elements – such as
tracking the progress of requests, listening for cancellation, and mapping payloads and headers. It also applies to all
the interceptors in the requesting lifecycle.

:::caution

If there is no XHR in the window object or the XHR object is a polyfill in your environment, you’ll have to install the
npm package [xmlhttprequest](https://www.npmjs.com/package/xmlhttprequest) and set it on the window object. Otherwise we
will use the node http module.

:::

---

## Preview

(@import HyperFetch adapter type=type=type=preview)

---

## Purpose

- Requests handler for client dispatchers
- Provides flexibility via handler changeability

---

## Related guides

- [Custom adapter](/guides/02-advanced/custom-adapter.mdx)

---
